
import java.util.Hashtable;

class P417 {

	private static Hashtable hashTable;

	public static void main(String[] args) {
		generate();
		String line = readLn();
		while (line != null) {
			process(line);
			line = readLn();
		}
	}

	// and so on until 5 nested loops... if everything is correct,
	// you'll fill in the indexes from 1 to 83681

	private static void generate() {
		int curIndex = 1;

		hashTable = new Hashtable();

		for (int i = 0; i < 26; i++) {
			hashTable.put((char)('a' + i) + "", curIndex + "");
			curIndex++;
		}
		for (int i = 0; i < 26; i++) {
			for (int j = i + 1; j < 26; j++) {
				hashTable.put((char)('a' + i) + "" + (char)('a' + j), curIndex + "");
				curIndex++;
			}
		}

		for (int i = 0; i < 26; i++) {
			for (int j = i + 1; j < 26; j++) {
				for (int k = j + 1; k < 26; k++) {
					hashTable.put((char)('a' + i) + "" + (char)('a' + j) + "" + (char)('a' + k), curIndex + "");
					curIndex++;
				}
			}
		}

		for (int i = 0; i < 26; i++) {
			for (int j = i + 1; j < 26; j++) {
				for (int k = j + 1; k < 26; k++) {
					for (int m = k + 1; m < 26; m++) {
						hashTable.put((char)('a' + i) + "" + (char)('a' + j) + "" + (char)('a' + k) + "" + (char)('a' + m), curIndex + "");
						curIndex++;
					}
				}
			}
		}

		for (int i = 0; i < 26; i++) {
			for (int j = i + 1; j < 26; j++) {
				for (int k = j + 1; k < 26; k++) {
					for (int m = k + 1; m < 26; m++) {
						for (int n = m + 1; n < 26; n++) {
							hashTable.put((char)('a' + i) + "" + (char)('a' + j) + "" + (char)('a' + k) + "" + (char)('a' + m) + "" + (char)('a' + n), curIndex
									+ "");
							curIndex++;
						}
					}
				}
			}
		}

//		System.out.println(hashTable);
	}

	private static void process(String line) {
		Object index =  hashTable.get(line);
		if (index == null) {
			System.out.println("0");
		} else {
			System.out.println(index);
		}

	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}